package com.example.server.web.controller;


import com.example.server.web.domain.RespBean;
import com.example.server.web.domain.page.PageQueryDto;
import com.example.server.web.domain.dto.TeacherAddDto;
import com.example.server.web.domain.dto.TeacherParamDto;
import com.example.server.web.service.SysUserService;
import com.example.server.web.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  教师 前端控制器
 * </p>
 *
 * @author 作者
 * @since 2023-04-04
 */
@RestController
@RequestMapping("/teacher")
@Api(tags = {"教师接口"})
public class TeacherController {

    @Autowired
    private TeacherService teacherService;

    @Autowired
    private SysUserService sysUserService;

    @ApiOperation("添加教师")
    @PostMapping("/addTeacher")
    public RespBean addTeacher(@RequestBody TeacherAddDto teacherAddDto){
        teacherService.addTeacher(teacherAddDto);
        return RespBean.success("添加成功");
    }

    @ApiOperation("查看教师分页数据")
    @GetMapping("/page")
    public RespBean addTeacher(PageQueryDto pageQueryDto, TeacherParamDto teacherParamDto){
        Map map = teacherService.getPage(pageQueryDto,teacherParamDto);
        return RespBean.success("查询成功",map);
    }

    @ApiOperation("修改教师")
    @PostMapping("/updateTeacher")
    public RespBean updateTeacher(@RequestBody TeacherAddDto teacherAddDto){
        teacherService.updateTeacher(teacherAddDto);
        return RespBean.success("修改成功");
    }

    @ApiOperation("删除教师")
    @PostMapping("/deleteTeacher")
    public RespBean deleteTeacher(@RequestBody List<Long> ids){
        teacherService.deleteTeacher(ids);
        return RespBean.success("修改成功");
    }

    @ApiOperation("查看教师详情信息")
    @GetMapping("/selectDetail/{id}")
    public RespBean selectDetail(@PathVariable("id") Long id){
        TeacherAddDto teacherAddDto = teacherService.selectDetail(id);
        return RespBean.success("查询成功",teacherAddDto);
    }
}
